
def ApplyPropertiesToObject(Props, Object, NameSpace = ''):

    def applyProp(Object, propName, value):
        obj = Object
        propNames = propName.split('.')
        for prop in propNames[:-1]:
            if hasattr(obj, prop):
                obj = getattr(obj, prop)
                continue
                return 

        name = propNames[(len(propNames) - 1)]
        if hasattr(obj, name):
            setattr(obj, name, value)


    if ((Object == None) or (len(Props.keys()) == 0)):
        return 
    PropsToApply = {}
    if (NameSpace != ''):
        TestNameSpace = (NameSpace + '.')
        NameSpaceLen = len(TestNameSpace)
        for each in Props.keys():
            if (each[0:NameSpaceLen] == TestNameSpace):
                PropsToApply[each[NameSpaceLen:]] = Props[each]

    else:
        PropsToApply = Props
    if (len(PropsToApply.keys()) == 0):
        return 
    for each in PropsToApply.keys():
        applyProp(Object, each, PropsToApply[each])




